<?php
namespace Home\Controller;
use Think\Controller;

class ChannelController extends Controller {

    public function index(){

        $Model = M('PictureCategory');

        $where['key'] = 'channel';
        $list = $Model->where($where)->order('rank desc')->select();

        $where['key'] = 'private';
        $private = $Model->where($where)->find();

        $listReturn = array();

        foreach($list as $v){

            $listReturn[] = array(
                'imgUrl'   => C('PICDOMAIN').C('PICPATH').$v['litpic'],
                'name'     => $v['name'],
                'key'      => $v['key'],
                'target'   => C('DOMAIN').'channel/lists/cid/'.$v['id']
            );
        }
        
        $listReturn[] = array(
            'imgUrl'    => C('PICDOMAIN').C('PICPATH').$private['litpic'],
            'name'      => $private['name'],
            'key'       => $private['key'],
            'target'    => C('DOMAIN').'private'
        );

        $this->ajaxReturn($listReturn);
    }

    public function lists(){

        $cid = I('get.cid');

        $Model = M('Picture');

        $where['cid'] = $cid;

        $list = $Model->where($where)->order('rank desc')->select();

        $listReturn = array();

        foreach($list as $v){
            $listReturn[] = array(
                'name'      => $v['name'],
                'imgUrl'    => C('PICDOMAIN').C('PICPATH').$v['litpic']
            );
        }

        $this->ajaxReturn($listReturn);

    }
}